package com.bawei.bydayzg_two

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.navigation.findNavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bawei.base.mvvm.BaseViewActivity
import com.bawei.bydayzg_two.databinding.ActivityShopBinding

@Route(path = "/app/ShopActivity")
class ShopActivity : BaseViewActivity<ActivityShopBinding>() {
    @Autowired
    @JvmField
    var index = 0
    //
    override fun getLoutyId(): Int {
        return R.layout.activity_shop
    }

    override fun initView() {
        ARouter.getInstance().inject(this)
        //
        //联动------只能点击切换
        //找到导航数珠
        val navHostFragment =
            supportFragmentManager.findFragmentById(R.id.fragmentContainerView) as NavHostFragment
        //找到导航控制器
        val navController = navHostFragment.navController
        //和底部导航进行联动
        binding.bnv.setupWithNavController(navController)

        //这样子使用嵌套会找不到id
//        binding.bnv.setupWithNavController(findNavController(R.id.fragmentContainerView))
        //
        when(index){
            0->{
                binding.bnv.selectedItemId = R.id.homeFragment
            }
            1->{
                binding.bnv.selectedItemId = R.id.capegoryFragment
            }
            2->{
                binding.bnv.selectedItemId = R.id.cartFragment
            }
            3->{
                binding.bnv.selectedItemId = R.id.mineFragment
            }
        }
    }

    override fun initDate() {

    }

}